﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HobSoft.SoccerBet2014.Common.Errors
{
    public class ValidResult
    {
        public ValidResult(bool result)
        {
            Result = result;
        }
        public bool Result { get; protected set; }
    }

    public static class Validate
    {
        public static ValidResult IsNull(this object value)
        {
            return value == null ? new ValidResult(true) : new ValidResult(false);
        }

        public static ValidResult IsNull<T>(this T value) where T : class
        {
            return value == null ? new ValidResult(true) : new ValidResult(false);
        }

        public static ValidResult Assert(this object value, bool condition)
        {
            return new ValidResult(condition);
        }

        public static ValidResult Assert<T>(this T value, Func<T, bool> check)
        {
            return new ValidResult(check(value));
        }

        public static ValidResult IsTrue(this bool condition)
        {
            return new ValidResult(condition);
        }

        public static ValidResult IsFalse(this bool condition)
        {
            return new ValidResult(!condition);
        }
    }
}
